/**
 * FileName: NursesServiceImpl
 * Author:   P
 * Date:     2021/4/8 14:43
 * Description:
 */
package com.hospital.nurse.service.Impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hospital.nurse.mapper.NursesMapper;
import com.hospital.nurse.pojo.Nurses;
import com.hospital.nurse.service.NursesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NursesServiceImpl extends ServiceImpl<NursesMapper, Nurses> implements NursesService {

    @Autowired
    private NursesMapper nursesMapper;

    @Override
    public boolean loginValid(Nurses nurses) {
        QueryWrapper<Nurses> wrapper = new QueryWrapper<>();
        wrapper.eq("username",nurses.getUsername());
        Nurses nurses1 = nursesMapper.selectOne(wrapper);
        if (nurses1==null || nurses1.equals(""))
            return false;
        if (!nurses.getPassword().equals(nurses1.getPassword())){
            return false;
        }
        return true;
    }

    @Override
    public Nurses getNurse(String username) {
        return nursesMapper.selectOne(new QueryWrapper<Nurses>().eq("username",username));
    }
}
